function acey_toast(content,msc) {
    var div = document.createElement("div");
    var str = "<div id='style' style='position: fixed;top:45%; left:25%;width: 50%;height: 8%;background: #333333;font-weight: bold;text-align: center;;line-height: 240%;font-size: 1em;color: white;padding: 2%;border-radius: 10px;' >"+content+"</div>"
    div.innerHTML = str;
    document.body.appendChild(div);
    setTimeout("acey_hide()", msc);
}
function acey_hide() {
    var acey_node =  document.getElementById("style");
    acey_node.parentNode.removeChild(acey_node);
}


//更新用户足迹
function updateFootprint(productId) {
    $.ajax({
        url:"http://obao.tunnel.2bdata.com/user_updateFootprint.htm?userId="+userId+"&productId="+productId,
        type:"post",
        success:function (data) {
        }
    })
}

//用户进入主页，判断用户localStorage 中是否有 openid,有就不保存，没有就发送请求查询用户信息保存到localStorage中
function saveOpenid() {
    //从地址中截取openid
    var data = location.href.split("?");
    if(data.length != 4){
        turn_to_auto();
    }
    var openid = data[1];
    var nickname = data[2];
    var headimgurl = data[3];
    setCookie("openid",openid,365);
    setCookie("nickname",nickname,365);
    setCookie("headimgurl",headimgurl,365);
}
//获取用户信息
function getUserInfo() {
    if(getCookie("openid") == null || getCookie("openid") ==""){
        turn_to_auto();
        return;
    }
    var userInfo = {
     "openid":getCookie("openid"),
     "nickname":getCookie("nickname"),         
     "headimgurl":getCookie("headimgurl")         
    }
    return userInfo;
}
//跳转授权
function turn_to_auto() {
    location.href = "http://obao.tunnel.2bdata.com/";
}

//cookie设置或获取
function setCookie(c_name,value,expiredays)
{
    var exdate=new Date()
    exdate.setDate(exdate.getDate()+expiredays)
    document.cookie=c_name+ "=" +escape(value)+
        ((expiredays==null) ? "" : ";expires="+exdate.toGMTString())
}

//取回cookie
function getCookie(c_name)
{
    if (document.cookie.length>0)
    {
        c_start=document.cookie.indexOf(c_name + "=")
        if (c_start!=-1)
        {
            c_start=c_start + c_name.length+1
            c_end=document.cookie.indexOf(";",c_start)
            if (c_end==-1) c_end=document.cookie.length
            return unescape(document.cookie.substring(c_start,c_end))
        }
    }
    return ""
}